class Animal{
    public String name;
    public int age;
/*    {
        System.out.println("3");
    }*/
    static {
        System.out.println("4");
    }
    public Animal(){

    }
    public Animal(String name, int age){//构造方法最后
        this.name = name;
        this.age = age;
        System.out.println("1");
    }
    {
        System.out.println("9");//实例代码块其次
    }
    public void func(){
        System.out.println(name + "吃饭！");
    }
}
class Dog extends Animal{
    public boolean silly;
    {
        System.out.println("5");
    }
    static {
        System.out.println("6");//静态代码块最先
    }
    public Dog(String name, int age, boolean silly){
        super(name, age);
        this.silly = silly;
        System.out.println("2");
    }
    public void bark(){
        System.out.println(name + "叫");
    }
}
class Cat extends Animal{
    /*public Cat(){
        super();
    }*/
    public void catchMouse(){
        System.out.println(name + "抓老鼠");
    }
}
public class Main {
    public static void main(String[] args) {
        Dog dog = new Dog("lisa", 12, false);
        dog.age = 12;
        dog.name = "lisa";
        dog.bark();
        System.out.println("============");

        Cat cat = new Cat();
        String s1 = "abcd";
        String s2 = "efg";
        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s1+s1);
        //JAVA中可以用+来拼接字符串
        //整形转字符串
        int a1 = 321;
        //方法1
        String s11 = a1+"";
        System.out.println(s11);
        //方法2
        String s12 = String.valueOf(a1);
        System.out.println(s12);
        //字符串转整形
        String s = "123";
        int a = Integer.parseInt(s);
        System.out.println(s);
    }
}
